package com.yanggu.scala.chapater04

object ForDemo01 {

  def main(args: Array[String]): Unit = {
    //1. for循环。左闭右闭
    for (i <- 1 to 3) {
      println(i)
    }

    //2. 输出10次，hello，尚硅谷
    val start = 1
    val  end = 10
    for (i <- start to end) {
      println("Hello, 尚硅谷")
    }

    //3. 直接对集合进行遍历
    val list = List("Hello", 1, 2, 3.4)
    list.foreach(item => println(item))
    for (item <- list) {
      println(item)
    }
  }

}
